package com.asia5b.a5mall.middleware.model.home

import android.text.TextUtils
import com.asia5b.a5mall.middleware.model.base.BaseModel
import com.asia5b.a5mall.middleware.utils.LocalManageUtil
import com.google.gson.annotations.SerializedName

/**
 * Created by zhangyuncai on 2019/12/21.
 * @Note   父分类model
 */
open class CategoryModel : BaseModel() {
    var checked = false

    /**分类父ID*/
    @SerializedName(value = "parentId", alternate = ["parent_id"])
    val parentId: Int = 0

    @SerializedName(value = "catId", alternate = ["category_id"])
    var catId = 0

    val image = ""//图片


    @SerializedName(value = "enName", alternate = ["name"])
    var enName = ""//英文名称


    @SerializedName(value = "cnName", alternate = ["cn_name"])
    var cnName = ""//中文名称


    @SerializedName(value = "msName", alternate = ["ms_name"])
    var msName = ""//马来西亚


    @SerializedName(value = "thName", alternate = ["th_name"])
    var thName = ""//泰国


    @SerializedName(value = "idName", alternate = ["id_name"])
    var idName = ""//印度尼西亚


    @SerializedName(value = "viName", alternate = ["vi_name"])
    var viName = ""//越南


    @SerializedName(value = "filName", alternate = ["fil_name"])
    var filName = ""//菲律宾


    /**分类名称*/
    fun showName(): String {
        val lang = LocalManageUtil.getAppLanguage()
        var name = ""
        when (lang) {
            LocalManageUtil.LANGUAGE_CN -> {
                name = cnName
            }
            LocalManageUtil.LANGUAGE_SU -> {
                name = idName
            }
            LocalManageUtil.LANGUAGE_MS -> {
                name = msName
            }
            LocalManageUtil.LANGUAGE_VI -> {
                name = viName
            }
            LocalManageUtil.LANGUAGE_TH -> {
                name = thName
            }
            else -> {
                name = enName
            }
        }
        if (TextUtils.isEmpty(name)) {
            name = enName
        }
        return name
    }

    val children: ArrayList<CategoryModel>? = null

}